let ZXHS = 'zx_history'

export const setZXHS = function (val, isDelete) {
    let arr = getZXHS()
    if (isDelete && val) {
        let arrs = arr.filter(item => {
            return item != val
        })
        localStorage.setItem(ZXHS, JSON.stringify(arrs))
    } else if (isDelete) {
        arr = []
        localStorage.setItem(ZXHS, JSON.stringify(arr))

    } else {
        if (arr.indexOf(val) >= 0) {
            let arrs = arr.filter(item => {
                return item != val
            })
            arrs.unshift(val)
            localStorage.setItem(ZXHS, JSON.stringify(arrs))

        } else {
            arr.unshift(val)
            localStorage.setItem(ZXHS, JSON.stringify(arr))

        }
    }

}
export const getZXHS = function () {
    return JSON.parse(localStorage.getItem(ZXHS)) || []
}
